package org.lisen.printhtmlstarter.service;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;
import java.net.URL;

/**
 * @author laughing
 * @date 2020/9/26
 * @site https://www.lisen.org
 */
public class PrintHtmlService {

    public void setUrl(String url) {
        this.url = url;
    }

    private String url;

    /**
     * 打印并返回html内容
     * @return
     * @throws IOException
     */
    public String print() throws IOException {
        Document document = Jsoup.parse(new URL(this.url), 300 * 1000);
        String htmlString = document.html();
        System.out.println(htmlString);
        return htmlString;
    }

}
